//
//  CustomViewCell.m
//  Great vision
//
//  Created by 大展 on 16/5/11.
//  Copyright © 2016年 张展. All rights reserved.
//

#import "DZZDiscoverCell.h"

@implementation DZZDiscoverCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}



- (void)cellOnTableView:(UITableView *)tableView didScrollOnView:(UIView *)view
{
    [self layoutIfNeeded];
    self.picView.contentMode =  UIViewContentModeScaleAspectFill;
    CGRect rectInSuperview = [tableView convertRect:self.frame toView:view];
    
    float distanceFromCenter = CGRectGetHeight(view.frame)/2 - CGRectGetMinY(rectInSuperview);
    float difference = CGRectGetHeight(self.picView.frame) - CGRectGetHeight(self.frame);
    float move = (distanceFromCenter / CGRectGetHeight(view.frame)) * difference;
    
    CGRect imageRect = self.picView.frame;
    imageRect.origin.y = -(difference/2)+move;
    self.picView.frame = imageRect;
}




@end
